import pygame
from pygame.locals import *

class Board(object):
    def __init__(self,orgimg, pieces):
        self.r = pygame.Rect(20,67,240,312)
        print "Dibujando recta "
        self.pieces = []
        self.orgimg = orgimg
        self.pieces = pieces
   
    def drop(self,piece):
        if piece.is_piece():
            if self.r.colliderect(piece.rect):
                destx = self.r.x+(64*piece.posx)-16
                desty = self.r.y+(64*piece.posy)-16
                if abs(piece.rect.x-destx)<=10 and abs(piece.rect.y-desty)<=10:
                    piece.set_pos(destx,desty)         
                    self.pieces.append(piece)
                    return True
            return False
        else:
            res = False
            for p in piece.pieces:
                res = self.drop(p)
            return res
       
    def draw(self,dest):
        print "Hola Mundo "
        #for p in self.pieces:
           # p.draw_shadow(dest,1)
        #if len(self.pieces) == 80:
        #dest.blit(self.orgimg,self.r.topleft)
        #else:
        #for p in self.pieces:
          #   p.draw(dest)
